import Vue from 'vue'
import Router from 'vue-router'

import Project from '../view/project' 
import Login from '../view/login' 
import Approval from '../view/approval' 
import ProjectAdd from '../view/projectAdd' 
import Register from '../view/register' 
import User from '../view/user' 
 
Vue.use(Router)  //Vue全局使用Router
 
export const constantRoutes=[              //配置路由，这里是个数组
    {                    
      path: '/project',     
      name: 'project',    
      component: Project   
    },
    {                    
      path: '/',         
      name: 'login',     
      component: Login   
    },
    {                    
      path: '/login',         
      name: 'login',     
      component: Login   
    },
    {                   
      path: '/approval',      
      name: 'approval',     
      component: Approval  
    },
    {                    
      path: '/projectAdd',         
      name: 'projectAdd',     
      component: ProjectAdd   
    },
    {                    
      path: '/register',         
      name: 'register',     
      component: Register   
    },
    {                    
      path: '/user',         
      name: 'user',     
      component: User   
    }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
